# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.FCMData.V1beta1.Model.GoogleFirebaseFcmDataV1beta1DeliveryPerformancePercents do
  @moduledoc """
  Overview of delivery performance for messages that were successfully delivered. All percentages are calculated with countMessagesAccepted as the denominator. These categories are not mutually exclusive; a message can be delayed for multiple reasons.

  ## Attributes

  *   `delayedDeviceDoze` (*type:* `number()`, *default:* `nil`) - The percentage of accepted messages that were delayed because the device was in doze mode. Only [normal priority messages](https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message) should be delayed due to doze mode.
  *   `delayedDeviceOffline` (*type:* `number()`, *default:* `nil`) - The percentage of accepted messages that were delayed because the target device was not connected at the time of sending. These messages were eventually delivered when the device reconnected.
  *   `delayedMessageThrottled` (*type:* `number()`, *default:* `nil`) - The percentage of accepted messages that were delayed due to message throttling, such as [collapsible message throttling](https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_throttling) or [maximum message rate throttling](https://firebase.google.com/docs/cloud-messaging/concept-options#device_throttling).
  *   `delayedUserStopped` (*type:* `number()`, *default:* `nil`) - The percentage of accepted messages that were delayed because the intended device user-profile was [stopped](https://firebase.google.com/docs/cloud-messaging/android/receive#handling_messages) on the target device at the time of the send. The messages were eventually delivered when the user-profile was started again.
  *   `deliveredNoDelay` (*type:* `number()`, *default:* `nil`) - The percentage of accepted messages that were delivered to the device without delay from the FCM system.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :delayedDeviceDoze => number() | nil,
          :delayedDeviceOffline => number() | nil,
          :delayedMessageThrottled => number() | nil,
          :delayedUserStopped => number() | nil,
          :deliveredNoDelay => number() | nil
        }

  field(:delayedDeviceDoze)
  field(:delayedDeviceOffline)
  field(:delayedMessageThrottled)
  field(:delayedUserStopped)
  field(:deliveredNoDelay)
end

defimpl Poison.Decoder,
  for: GoogleApi.FCMData.V1beta1.Model.GoogleFirebaseFcmDataV1beta1DeliveryPerformancePercents do
  def decode(value, options) do
    GoogleApi.FCMData.V1beta1.Model.GoogleFirebaseFcmDataV1beta1DeliveryPerformancePercents.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.FCMData.V1beta1.Model.GoogleFirebaseFcmDataV1beta1DeliveryPerformancePercents do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
